package com.ysd.lis.controller.sys;


import com.ysd.common.Result;
import com.ysd.lis.controller.pub.BaseController;
import com.ysd.lis.dto.SysUserDeptDto;
import com.ysd.lis.entity.SysUserDepartment;
import com.ysd.lis.request.CommonPageDto;
import com.ysd.lis.service.SysUserDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户报告单元关系表 前端控制器
 * </p>
 *
 * @author prs
 * @since 2024-12-13
 */
@Api(tags = "用户与科室对应")
@RestController
@RequestMapping("/api/userDepartment")
public class SysUserDepartmentController extends BaseController {

    @Autowired
    public SysUserDepartmentService sysUserDepartmentService;

    @ApiOperation("根据用户id查询报告单元id")
    @GetMapping("/findSysUserDepartmentList/{userId}")
    public Result findSysUserDepartmentList(@PathVariable("userId") String userId) {
        return sysUserDepartmentService.findSysUserDepartmentList(userId);
    }
    @ApiOperation("添加用户与报告单元对应关系")
    @PostMapping("/addSysUserDepartment")
    public Result addSysUserDepartment(@RequestBody SysUserDepartment sysUserDepartment) {
        return sysUserDepartmentService.addSysUserDepartment(sysUserDepartment);
    }
    @ApiOperation("批量添加用户与报告单元对应关系")
    @PostMapping("/addBatchSysUserDepartment")
    public Result addBatchSysUserDepartment(@RequestBody List<SysUserDepartment> sysUserDepartments) {
        return sysUserDepartmentService.addBatchSysUserDepartment(sysUserDepartments);
    }
    @ApiOperation("删除用户与报告单元对应关系")
    @PostMapping("/deleteSysUserDepartment")
    public Result deleteSysUserDepartment(@RequestBody SysUserDepartment sysUserDepartment) {
        return sysUserDepartmentService.deleteSysUserDepartment(sysUserDepartment);
    }
    @ApiOperation("查询")
    @GetMapping("/findUserDepartmentList")
    public Result findUserDepartmentList(CommonPageDto pageParam){
        return sysUserDepartmentService.findUserDepartmentList(pageParam);
    }

    @ApiOperation("批量删除")
    @PostMapping("/batchDeleteUserDepartmentList")
    public Result batchDeleteUserDepartmentList(@RequestBody SysUserDeptDto dto){
        return  sysUserDepartmentService.batchDeleteUserDepartmentList(dto);
    }
    @ApiOperation("批量新增")
    @PostMapping("/batchAddSysUserDepartList")
    public Result batchAddSysUserDepartList(@RequestBody SysUserDeptDto dto){
        return  sysUserDepartmentService.batchAddSysUserDepartList(dto);
    }

}
